import request from "@/utils/request";

export function getTaskCategory(){
    return request({
        url: '/api/category/categories',
        method: 'get',
    })
}

export function getProduct(categoryId, page, size){
    return request({
        url: '/api/spu',
        method: 'get',
        params: {categoryId, page, size}
    })
}

export const searchProducts = (dto) => {
  return request.post('/api/spu/search',  dto );
};
/**
 * 获取商品详情（包含SKU信息）
 * @param {number|string} productId - 商品ID
 * @returns {Promise} - 返回后端响应数据
 */
export const getProductWithSku = (productId) => {
  return request({
    url: `/api/spu/${productId}/with-sku`,
    method: 'get'
  });
};

export function getPendingSpus(pageNum = 1, pageSize = 10) {
  return request.get('/api/spu/pending', {
    params: { pageNum, pageSize }
  })
}

export function approveSpu(spuId) {
  return request.post(`/api/spu/${spuId}/approve`)
}

export function rejectSpu(spuId) {
  return request.post(`/api/spu/${spuId}/reject`)
}

// 获取商品评价
export const getProductEvaluationsService = (spuId, page = 1, size = 10) => {
  return request({
    url: '/api/evaluation/product',
    method: 'get',
    params: { spuId, page, size }
  });
};